function createSql(){
	var env=$('#envsel').find('option:selected').text();
	var version=$('#versioninput').val();
	var upgadeType=$('input:radio[name="upgradetype"]:checked').val();
	var appType=$('input:radio[name="apptype"]:checked').val();
	var osType=$('input:radio[name="ostype"]:checked').val();
	var ver=version.split('.').join('');
	var upgradeSql="";
	if(env=='--请选择环境--'){
		layer.msg('请选择环境',{icon:2});
	}
	else if(version==''){
		layer.msg('版本不能为空，请选择版本！',{icon:2});
	}
	else{
		if(env=='测试环境'){
			if(appType=='0'){
				if(osType=='0'){
					upgradeSql="INSERT INTO `danlu_cd_database`.`t_app_version_management` (`id`, `app_download_address`, `version`, `is_force_upgrade`, `os_code`, `os_name`, `equipment_code`, `equipment_name`, `created_timestamp`, `app_type`) VALUES "+
					"('ca1692101f40477c9122dc2zddand"+ver+"', 'http://asset.danlu.com/mobile/test/android/danlu_store_v"+version+".apk', '"+version+"', '"+upgadeType+"', '0', 'android', '0', 'phone','"+getNowTime()+"', '"+appType+"');";
				}
				else{
					upgradeSql="INSERT INTO `danlu_cd_database`.`t_app_version_management` (`id`, `app_download_address`, `version`, `is_force_upgrade`, `os_code`, `os_name`, `equipment_code`, `equipment_name`, `created_timestamp`, `app_type`) VALUES "+
					"('ca1692101f40477c9122dc2zddand"+ver+"', '', '"+version+"00', '"+upgadeType+"', '1', 'ios', '0', 'phone', '"+getNowTime()+"', '"+appType+"');";
				}
			
			}
			else{
				if(osType=='0'){
					upgradeSql="INSERT INTO `danlu_cd_database`.`t_app_version_management` (`id`, `app_download_address`, `version`, `is_force_upgrade`, `os_code`, `os_name`, `equipment_code`, `equipment_name`, `created_timestamp`, `app_type`) VALUES "+
					"('ca1692101f40477c9122dc2jxsand"+ver+"', 'http://asset.danlu.com/mobile/test/android/danlu_dealer_v"+version+".apk', '"+version+"', '"+upgadeType+"', '0', 'android', '0', 'phone','"+getNowTime()+"', '"+appType+"');";
				}
				else{
					upgradeSql="INSERT INTO `danlu_cd_database`.`t_app_version_management` (`id`, `app_download_address`, `version`, `is_force_upgrade`, `os_code`, `os_name`, `equipment_code`, `equipment_name`, `created_timestamp`, `app_type`) VALUES "+
					"('ca1692101f40477c9122dc2jxsand"+ver+"', '', '"+version+"00', '"+upgadeType+"', '1', 'ios', '0', 'phone', '"+getNowTime()+"', '"+appType+"');";
				}
			
			}
		}
	else{
		if(appType=='0'){
			if(osType=='0'){
				upgradeSql="INSERT INTO `danlu_cd_database`.`t_app_version_management` (`id`, `app_download_address`, `version`, `is_force_upgrade`, `os_code`, `os_name`, `equipment_code`, `equipment_name`, `created_timestamp`, `app_type`) VALUES "+
				"('ca1692101f40477c9122dc2zddand"+ver+"', 'http://asset.danlu.com/mobile/client/android/danlu_store_v"+version+".apk', '"+version+"', '"+upgadeType+"', '0', 'android', '0', 'phone','"+getNowTime()+"', '"+appType+"');";
			}
			else{
				upgradeSql="INSERT INTO `danlu_cd_database`.`t_app_version_management` (`id`, `app_download_address`, `version`, `is_force_upgrade`, `os_code`, `os_name`, `equipment_code`, `equipment_name`, `created_timestamp`, `app_type`) VALUES "+
				"('ca1692101f40477c9122dc2zddand"+ver+"', '', '"+version+"00', '"+upgadeType+"', '1', 'ios', '0', 'phone', '"+getNowTime()+"', '"+appType+"');";
			}
		}
		else{
			if(osType=='0'){
				upgradeSql="INSERT INTO `danlu_cd_database`.`t_app_version_management` (`id`, `app_download_address`, `version`, `is_force_upgrade`, `os_code`, `os_name`, `equipment_code`, `equipment_name`, `created_timestamp`, `app_type`) VALUES "+
				"('ca1692101f40477c9122dc2jxsand"+ver+"', 'http://asset.danlu.com/mobile/client/android/danlu_dealer_v"+version+".apk', '"+version+"', '"+upgadeType+"', '0', 'android', '0', 'phone','"+getNowTime()+"', '"+appType+"');";
			}
			else{
				upgradeSql="INSERT INTO `danlu_cd_database`.`t_app_version_management` (`id`, `app_download_address`, `version`, `is_force_upgrade`, `os_code`, `os_name`, `equipment_code`, `equipment_name`, `created_timestamp`, `app_type`) VALUES "+
				"('ca1692101f40477c9122dc2jxsand"+ver+"', '', '"+version+"00', '"+upgadeType+"', '1', 'ios', '0', 'phone', '"+getNowTime()+"', '"+appType+"');";
			}
		}
	}
	$('#upgradeSqlInfo').html(upgradeSql);
		
	}
}

function getNowTime(){
		var myDate = new Date();
		//获取当前年
		var year=myDate.getFullYear();
		//获取当前月
		var month=myDate.getMonth()+1;
		//获取当前日
		var date=myDate.getDate(); 
		var h=myDate.getHours();       //获取当前小时数(0-23)
		var m=myDate.getMinutes();     //获取当前分钟数(0-59)
		var s=myDate.getSeconds(); 
		var now=year+"-"+p(month)+"-"+p(date)+" "+p(h)+":"+p(m)+":"+p(s);
		return now;
	}
	
	function p(s) {
		return s < 10 ? ('0' + s): s;
	}
	
	
function copySql(){
	var clipboard = new Clipboard('#copybtn', {
        text: function() {
			var info=$('#upgradeSqlInfo').text();
            return info;
        }
    });

    clipboard.on('success', function(e) {
		layer.msg('复制成功',{icon:1});
        console.log(e);
    });

    clipboard.on('error', function(e) {
        console.log(e);
    });
}